﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace InsertionSort
{
    public class Program
    {
        public static void InsertionSort<T>(T[] array) where T : IComparable<T>
        {
            for (int i = 0; i < array.Length; i++)
            {
                int index = i;
                while (index > 0 && array[index].CompareTo(array[index - 1]) < 0)
                {
                    T temp = array[index - 1];
                    array[index - 1] = array[index];
                    array[index] = temp;
                    index--;
                }
            }
        }

        public static void Main()
        {
            int[] array = { 2, 5, 1, 3, 7, 4, 5 };
            InsertionSort(array);
        }
    }
}
